package stark.app.function.visualai;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;

import com.blankj.utilcode.util.ArrayUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;

import stark.app.R;
import stark.app.base.BaseWithFragmentActivity;
import stark.app.databinding.FragmentVisualAiFuncListBinding;
import stark.common.basic.base.BaseNoModelFragment;

/**
 * Author：daizhongbin on 2023/10/11
 * Email：1027154338@qq.com
 * Desc:
 */
public class VisualAiFuncListFragment extends BaseNoModelFragment<FragmentVisualAiFuncListBinding> {
    @Override
    protected int onCreate() {
        return R.layout.fragment_visual_ai_func_list;
    }

    @Override
    protected void initView() {
        GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 2);
        mDataBinding.rvFunc.setLayoutManager(layoutManager);
        VisualAiFuncAdapter adapter = new VisualAiFuncAdapter(2);
        adapter.addChildClickViewIds(R.id.btnName);
        adapter.setOnItemChildClickListener(this);
        adapter.setNewInstance(ArrayUtils.asList(VisualAiFuncType.values()));
        mDataBinding.rvFunc.setAdapter(adapter);
    }

    @Override
    protected void initData() {
    }

    @Override
    protected void onItemClickCallback(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
        VisualAiFuncType funcType = (VisualAiFuncType) adapter.getItem(position);
        BaseWithFragmentActivity.start(getContext(), funcType.getName(), VisualAiFuncFragment.class, VisualAiFuncFragment.createArguments(funcType));
    }

}
